﻿@using Microsoft.AspNetCore.Mvc.Controllers
@using Urs.Core
@using Urs.Core.Plugins
@using Urs.Services.Authentication.External
@using Urs.Services.Cms
@using Urs.Services.Common
@using Urs.Services.Payments
@using Urs.Services.Plugins
@using Urs.Services.Shipping
@inject IPluginFinder pluginFinder
@inject IWebHelper webHelper
@{
    var plugin = PluginManager.FindPlugin((this.ViewContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo).Instance();

    //friendly name
    var friendlyName = plugin?.PluginDescriptor.FriendlyName;

    var activeMenuSystemName = string.Empty;
    var configureLocale = string.Empty;
    var listActionMethodName = string.Empty;
    var listControllerName = string.Empty;

    if (plugin is IPaymentMethod)
    {
        //payment plugin
        activeMenuSystemName = "PaymentMethods";
        configureLocale = "Admin.Configuration.Payment.Methods.Configure";
        listActionMethodName = "PaymentMethods";
        listControllerName = "Payment";
    }
    else if (plugin is IShippingRateComputationMethod)
    {
        //shipping rate computation method
        activeMenuSystemName = "Shipping providers";
        configureLocale = "Admin.Configuration.Shipping.Providers.Configure";
        listActionMethodName = "Providers";
        listControllerName = "Shipping";
    }
    else if (plugin is IExternalAuthenticationMethod)
    {
        //external auth method
        activeMenuSystemName = "External authentication methods";
        configureLocale = "Admin.Configuration.ExternalAuthenticationMethods.Configure";
        listActionMethodName = "Methods";
        listControllerName = "ExternalAuthentication";
    }
    else if (plugin is IWidgetPlugin)
    {
        //widgets
        activeMenuSystemName = "Widgets";
        configureLocale = "Admin.ContentManagement.Widgets.Configure";
        listActionMethodName = "List";
        listControllerName = "Widget";
    }
    else if (plugin is IMiscPlugin)
    {
        //Misc plugins
        activeMenuSystemName = "Plugins";
        configureLocale = "Admin.Configuration.Plugins.Misc.Configure";
        listActionMethodName = "List";
        listControllerName = "Plugin";
    }

    Layout = "_AdminLayout";
    //page title
    ViewBag.Title = T(configureLocale).Text + " - " + friendlyName;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName(activeMenuSystemName);

}
<div class="content-header clearfix">
    <h1 class="pull-left">
        @T(configureLocale) - @friendlyName
        <small>
            <i class="fa fa-arrow-circle-left"></i>
            <a asp-action="List" asp-controller="Plugin" asp-area="Admin">@T("Admin.Common.BackToList")</a>
        </small>
    </h1>
    <div class="pull-right">
        &nbsp;
    </div>
</div>
<div class="content">
    <div class="form-horizontal">
         @RenderBody()
    </div>
</div>
